<?php
class skinsMod extends commonMod
{
	public function __construct()
	{
		parent::__construct();

	}
	public function index()
	{
		//遍历风格读取配置参数
		$dir	= '../template';
		$list	= scandir($dir);
		foreach($list as $file)
		{
			$file_location=$dir."/".$file;
			if(is_dir($file_location) && $file!="." &&$file!="..")
			{
				$arr_file1[] = $file;
			}
		}
		$i = 0;
		if(is_array($arr_file1))
		{
			foreach($arr_file1 as $val)
			{
				$xml_array = simplexml_load_file('../template/'.$val.'/config.xml');
				$style[$i]['SiteName']	= $xml_array->SiteName;
				$style[$i]['FileName']	= $xml_array->FileName;
				$style[$i]['SiteMaster']= $xml_array->SiteMaster;
				$style[$i]['PubDate']	= $xml_array->PubDate;
				$style[$i]['StyleType']	= $xml_array->StyleType;
				$style[$i]['summary']	= $xml_array->summary;
				$style[$i]['pic']		= '/template/'.$val.'/'.$xml_array->pic;
				$i++;
			}
		}
		$this->assign('now_style',$this->config['DEFAULT_STYLE']);
		$this->assign('style',$style);
		$this->display();
	}
	//删除风格
	public function del()
	{
		$dir_name = "../template/".$_GET[0];
		if($this->config['DEFAULT_STYLE']==$_GET[0])
		{
			$this->error('风格正在使用禁止删除！');
		}
		else
		{
			del_dir($dir_name);
			$this->success('删除风格成功！');
		}
	}
	
	//风格设置
	public function save()
	{
		$config['DEFAULT_STYLE'] = $_GET[0];
		$config_array			 = array();
		foreach($config as $key=>$value)
		{
			$config_array["config['".$key."']"] = $value;	
		}
		if(!$this->set_config($config_array))
		{
			$this->error('风格设置失败！');
		}
		else
		{
			$this->success('风格设置成功！');
		}
	}

}
?>